#pragma once
#include "../protocol/p2pprotocol.hpp"
#include "../../../include/singleton.h"
#define MAX_PKG_SIZE    1024

class CP2P;

class CP2PProtocolImpl :
    public Cp2pprotocol
{
public:
    CP2PProtocolImpl(CP2P* p2p);
    virtual ~CP2PProtocolImpl(void);

    virtual void OnRecv_LoginAck(LoginAck& rstProtocol);
    virtual void OnRecv_NATTestAck(NATTestAck& rstProtocol);

    virtual void OnRecv_ConnectPeerAck(ConnectPeerAck& rstProtocol);
    virtual void OnRecv_PeerConnectReq(PeerConnectReq& rstProtocol);

    virtual void OnRecv_P2PHandleReq(P2PHandleReq& rstProtocol);
    virtual void OnRecv_P2PHandleAck(P2PHandleAck& rstProtocol);

    bool HandleClientPkg(char* net_data, int net_size);
    int BuildPkg(void* host, char*& net);
protected:
    char    m_recv_pkg_cache[MAX_PKG_SIZE];
    char    m_send_pkg_cache[MAX_PKG_SIZE];
    CP2P*   m_p2p;
};
